03 / 05

How to terminate spot instances?

Terminate Spot Instances directly via EC2 console, AWS CLI, or SDK; for Spot Fleets, you can terminate individual instances or cancel the entire fleet request with instance termination.

You can terminate Spot Instances the same way you terminate On-Demand Instances: via the EC2 console, AWS CLI (terminate-instances), or SDK. However, termination behavior differs based on how the instance was launched. For instances launched from a one-time Spot request, terminating the instance also cancels the request. For persistent requests, terminating the instance causes a new instance to launch automatically to maintain capacity.

Terminate Individual Spot Instance via AWS CLI
Cancel Spot Fleet Request and Terminate Instances
Cancel Spot Fleet Request WITHOUT Terminating Instances
Important Restrictions for Stopping Spot Instances
  1. 1

    You can only stop a Spot Instance if it was launched from a persistent Spot Instance request [citation:1]

  2. 2

    You cannot stop a Spot Instance if the associated Spot request has been cancelled [citation:1]

  3. 3

    You cannot stop a Spot Instance if it is part of a fleet, launch group, or Availability Zone group [citation:1]

  4. 4

    When you stop a Spot Instance from a persistent request, the request enters a disabled state and will not automatically restart the instance [citation:8]

  5. 5

    If you terminate a Spot Instance from a persistent request, a new instance launches automatically to maintain capacity [citation:8]

Difficulty: 5/10
Topics: Spot Instance Lifecycle, Termination Handling, Cost Optimization

Scenario Questions

0-2 years experience
  1. 1

    You have an Auto Scaling group using spot instances. How would you manually terminate a specific spot instance without affecting the rest of the group?

  2. 2

    If you need to shut down all spot instances in a region at the end of the day to avoid extra charges, what steps would you take using the AWS console or CLI?

  3. 3

    What happens to the EBS volumes attached to a spot instance when you terminate it, and how would you ensure data is preserved?

2-5 years experience
  1. 1

    Your application is experiencing unexpected termination of spot instances during a scaling event. Walk me through how you would investigate and fix the termination behavior.

  2. 2

    Explain the trade‑offs between using the EC2 Spot Instance termination notice versus setting a lifecycle hook to gracefully drain instances before termination.

  3. 3

    You need to implement an automated script that terminates spot instances when a custom CloudWatch metric exceeds a threshold. What AWS services and API calls would you use, and why?

5-8 years experience
  1. 1

    Design a resilient processing pipeline that uses spot instances but must guarantee no data loss when instances are terminated. How would you handle termination events and coordinate work re‑assignment?

  2. 2

    At scale, terminating spot instances can cause a surge of replacement instances. How would you architect the termination and replacement flow to avoid a thundering herd and stay within service limits?

  3. 3

    Discuss how you would modify an existing Kubernetes cluster on EKS that currently runs on on‑demand instances to migrate workloads to spot instances, ensuring graceful termination and minimal disruption.

8+ years experience
  1. 1

    Your organization wants to shift 70% of its compute to spot instances across multiple accounts and regions. What cross‑team governance, tagging, and automation strategies would you put in place to manage termination policies, cost reporting, and compliance?

  2. 2

    Explain how you would redesign the company's CI/CD pipeline to incorporate spot instance termination handling, considering long‑running jobs, rollback safety, and coordination with other services.

  3. 3

    When legacy workloads rely on instance‑store storage, how would you approach migrating them to spot instances while handling termination and data persistence at an enterprise scale?

Follow-up Questions

  • Can you walk me through the exact CLI command you’d use?
  • How would you verify that termination completed successfully?
  • What would you monitor to detect unexpected spot terminations?